# Copyright (c) 2005,2006,2007 Dynamic Solutions Inc. (support@dynamic-solutions.com)
#
# This file is part of DataZoomer.
#
# DataZoomer is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# DataZoomer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""DataZoomer error objects"""


class DataZoomerError( RuntimeError ): pass

class IniFileMissing( DataZoomerError ):
    def __init__(self):
        DataZoomerError.__init__(self,'The datazoomer .ini file is inaccessible (dz.ini).')

class ThemeDoesNotExist( DataZoomerError ):
    def __init__(self,themename):
        DataZoomerError.__init__(self,'The theme, "%s", does not exist.' % themename)

""" base_error_page:
to avoid the problem of a bad install, not being able to find a theme template and then displaying
an error about not being able to find the template vs. the original error we have an interanl
error template here.  Add ability to override via .ini file.
"""
base_error_page = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <meta name="author" content="Dynamic Solutions Inc." />
    <meta name="keywords" content="Dynamic Solutions Inc., DSI, DataZoomer" />
    <meta name="description" content="A platform and a suite of tools that will foster a community where users and developers work together to create practical open source web applications using Python." />
    <meta name="robots" content="noindex, nofollow" />
    <meta name="googlebot" content="noarchive" />
    <title>DataZoomer: Unfortunately...</title>
    <style type="text/css" media="screen">
        #dz-error {margin-top: 5%;font: 1em Geneva, Arial, Tahoma, sans-serif;font-weight: normal;}
        #main {width: 660px;margin-left: auto;margin-right: auto;text-align: center;}
        #main.h1 {font-weight: bolder;}
        #logo {text-indent: -5000px;background: url(http://datazoomer.org/devbannerlogo.png) no-repeat 0px 0px;
                width: 200px;height: 50px;margin-left: 2em;margin-bottom: 1em;}
        #preamble {margin-bottom: 1em;padding: 1em;line-height: 1.6em;sbackground-color: #D6DFE8;background-color: #D6E8DF;text-align: left;
                    -moz-border-radius-topright:    1em;-moz-border-radius-topleft: 1em;
                    -moz-border-radius-bottomright: 1em;-moz-border-radius-bottomleft:  1em;}
        #preamble p { margin-bottom: 1.2em; }
        .highlight { font-weight: bolder; font-variant: small-caps; }
        .signature {font-family: "Century Gothic", Verdana, sans-serif;text-align:right;margin-top: 2em;margin-right: 3em;}
        #footer { margin-top: 1.2em }
        #footer a{ text-decoration: none; color: #8095AF; padding-bottom: 1px; border-bottom: 1px solid #333 }
        #footer a:visited{ border-bottom: 1px solid #CCC }
        #footer a:hover{ border-bottom: 1px dotted #000 }
    </style>

    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <link rel="top" title="DataZoomer" href="http://datazoomer.org/" />
    <link rel="help" title="DataZoomer Help" href="http://help.datazoomer.com/" />
    <link rel="alternate" type="application/rss+xml" title="RSS" href="http://datazoomer.org/datazoomer.xml" />
</head>

<body id="dz-error">
  <div id="main">
    <div id="logo" title="Datazoomer">DataZoomer</div>
    <div id="preamble">
        <p><span class="highlight">Unfortunately</span> DataZoomer has just discovered an error.</p>
        <p>The <span class="highlight">good news</span> is that you have just helped the
           DataZoomer team find an undesired bug and we assure you we will be looking into it.</p>
        <p>Sorry for the trouble, but we thank you for your help and support!</p>
        <p class="signature">~ The DataZoomer Team</p>
    </div>
    <div id="footer">
        <a href="/" title="Go to DataZoomer">Home</a> &nbsp;
        <a href="http://help.datazoomer.com/" title="Look through the DataZoomer Help section to try and solve the problem">Help</a> &nbsp;
        <a href="usagepolicy.htm" title="Check the DataZoomer terms of use">Terms of Use</a> &nbsp;
    </div>
  </div>
</body>
</html>
"""

base_error_message = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <meta name="author" content="Dynamic Solutions Inc." />
    <meta name="keywords" content="Dynamic Solutions Inc., DSI, DataZoomer" />
    <meta name="description" content="A platform and a suite of tools that will foster a community where users and developers work together to create practical open source web applications using Python." />
    <meta name="robots" content="noindex, nofollow" />
    <meta name="googlebot" content="noarchive" />
    <title>DataZoomer: Unfortunately...</title>

    <style type="text/css" media="screen">
        #dz-error {margin-top: 5%;font: 1em Geneva, Arial, Tahoma, sans-serif;font-weight: normal;}
        #main {width: 660px;margin-left: auto;margin-right: auto;text-align: center;}
        #main.h1 {font-weight: bolder;}
        #logo {text-indent: -5000px;background: url(http://datazoomer.org/devbannerlogo.png) no-repeat 0px 0px;
                width: 200px;height: 50px;margin-left: 2em;margin-bottom: 1em;}
        #preamble {margin-bottom: 1em;padding: 1em;line-height: 1.6em;sbackground-color: #D6DFE8;background-color: #D6E8DF;text-align: left;
                    -moz-border-radius-topright:    1em;-moz-border-radius-topleft: 1em;
                    -moz-border-radius-bottomright: 1em;-moz-border-radius-bottomleft:  1em;}
        #preamble p { margin-bottom: 1.2em; }
        .highlight { font-weight: bolder; font-variant: small-caps; }
        .signature {font-family: "Century Gothic", Verdana, sans-serif;text-align:right;margin-top: 2em;margin-right: 3em;}
        #footer { margin-top: 1.2em }
        #footer a{ text-decoration: none; color: #8095AF; padding-bottom: 1px; border-bottom: 1px solid #333 }
        #footer a:visited{ border-bottom: 1px solid #CCC }
        #footer a:hover{ border-bottom: 1px dotted #000 }
    </style>

    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <link rel="top" title="DataZoomer" href="/" />
    <link rel="help" title="DataZoomer Help" href="http://help.datazoomer.com/" />
    <link rel="alternate" type="application/rss+xml" title="RSS" href="http://datazoomer.org/datazoomer.xml" />
</head>

<body id="dz-error">
  <div id="main">
    <div id="logo" title="Datazoomer">DataZoomer</div>
    <div id="preamble">
        <p><#MSG></p>
    </div>
    <div id="footer">
        <a href="/" title="Go to DataZoomer">Home</a> &nbsp;
        <a href="http://help.datazoomer.com/" title="Look through the DataZoomer Help section to try and solve the problem">Help</a> &nbsp;
        <a href="usagepolicy.htm" title="Check the DataZoomer terms of use">Terms of Use</a> &nbsp;
    </div>
  </div>
</body>
</html>
"""